<template>
  <div class="login-box">
    <div class="login-container">
      <h3 class="login-title">Smartint 后台管理系统登录</h3>

      <div class="login-row">
        <span class="input-title">用户名：</span>
        <el-input
          v-model="userName"
          placeholder="请输入用户名"
          class="input-filed"
          size="small"
          autofocus
        ></el-input>
      </div>

      <div class="login-row">
        <span class="input-title">密码：</span>
        <el-input
          v-model="password"
          placeholder="请输入密码"
          class="input-filed"
          size="small"
          type="password"
        ></el-input>
      </div>

      <el-button
        class="login-btn"
        label="large"
        @click="login"
        :loading="loading"
      >
        <span v-if="!loading">登录</span>
        <span v-else>登录中...</span>
      </el-button>

      <p class="version">Version 1.0.0</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userName: '',
      password: '',
      loading: false
    }
  },
  mounted() {

  },
  methods: {
    login() {
      this.loading = true;
      setTimeout(() => {
        // 设置token
        sessionStorage.setItem('token', '0000')
        this.loading = false;
        this.$router.push('/index')
      }, 500)
    }
  }
}
</script>

<style scoped>
.login-box {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  background: url('../assets/u0.jpg') no-repeat center center fixed;
  background-size: cover;
}
.login-container {
  width: 35%;
  background-color: #fff;
  box-shadow: 5px 5px 5px rgba(0,0,0,0.3);
  border-radius: 5px;
  padding: 20px;
  text-align: center;
}
.login-title {
  font-size: 30px;
  margin-bottom: 30px;
}
.login-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}
.input-title {
  display: inline-block;
  font-size: 16px;
  text-align: right;
  line-height: 30px;
  margin-right: 10px;
  width: 80px;
}
.input-filed {
  width: 200px;
  text-align: left;
}
.login-btn {
  margin-top: 10px;
  width: 150px;
  font-size: 14px;
}
.version {
  margin-top: 20px;
  font-size: 12px;
}
</style>
